package com.aaa.service.back.Impl;

import com.aaa.entity.Modules;
import com.aaa.mapper.back.ModulesMapper;
import com.aaa.service.back.ModulesService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ModulesServiceImpl implements ModulesService {

    @Resource
    private ModulesMapper mm;


    /**
     * 根据职位查询模块
     * @param positionId
     * @return
     */
    @Override
    public List<Modules> findModulesByPosId(Integer positionId) {
        Map<String,Object> map=new HashMap<String,Object>();
        map.put("positionId",positionId);
        map.put("moduleCode","ROOT");
        //查询一级模块
        List<Modules> lm = mm.findModulesByPosId(map);
        for(Modules m:lm){
            map.put("moduleCode",m.getModuleCode());
            //查询二级模块
            List<Modules> sm=mm.findModulesByPosId(map);
            m.setSubModules(sm);
        }
        return lm;
    }
}
